from selenium.webdriver.common.by import By

from base.base_action import BaseAction


class ContactPage(BaseAction):
    name_label = By.XPATH, '//*[@text="姓名"]'
    mobile_label = By.XPATH, '//*[@text="电话"]'
    back_button_label = By.XPATH, '//*[@content-desc="向上导航"]'
    get_name_text_label = By.ID, 'com.android.contacts:id/large_title'
    get_mobile_text_label = By.ID, 'com.android.contacts:id/header'

    def input_name(self, name):
        self.send_keys(self.name_label, name)

    def input_mobile(self, mobile):
        self.send_keys(self.mobile_label, mobile)

    def click_back_button(self):
        self.click(self.back_button_label)

    def get_name(self):
        return self.get_text(self.get_name_text_label)

    def get_mobile(self):
        return self.get_text(self.get_mobile_text_label).replace(' ', '')
